package com.hyh.shiyanshiguanli.mapper;


import com.github.pagehelper.Page;
import com.hyh.shiyanshiguanli.domain.dto.PageDTO;
import com.hyh.shiyanshiguanli.domain.dto.StorageAddDTO;
import com.hyh.shiyanshiguanli.domain.entity.Instrument;
import com.hyh.shiyanshiguanli.domain.entity.Reagent;
import org.apache.ibatis.annotations.*;

/**
 * @author hyh
 * @version 1.0
 */
@Mapper
public interface LibAssetMapper {


    Page<Instrument> pageInstrument(PageDTO pageDTO);

    Page<Reagent> pageShiJi(PageDTO pageDTO);

    @Insert("insert into instrument (name, num, model, buy_date, other, factory) " +
            "values (#{name},#{num},#{model},#{buyDate},#{other},#{factory})")
    void addInstrument(Instrument instrument);

    @Insert("insert into reagent (name, num, model, buy_date, other, factory) " +
            "values (#{name},#{num},#{model},#{buyDate},#{other},#{factory})")
    void addReagent(Reagent reagent);

    @Select("select * from instrument where name = #{name} and model = #{model} and factory =#{factory} and other = #{other}")
    Instrument selectByName(StorageAddDTO storageAddDTO);

    @Update("update instrument set num = num +#{num} where id = #{id}")
    void addNum(@Param("num") Integer num,@Param("id") Integer id);

    @Select("select * from reagent where name = #{name} and model = #{model} and factory =#{factory} and other = #{other}")
    Reagent selectByRName(StorageAddDTO storageAddDTO);

    @Update("update reagent set num = num + #{num} where id = #{id}")
    void addRNum(@Param("num") Integer num,@Param("id")  Integer id);
}
